Skip to content

feat(core): implement parseMemory with structured section extraction#747

Open
Alexi5000 wants to merge 1 commit into
Signet-AI:mainfrom
Alexi5000:pr/implement-parse-memory
Open

feat(core): implement parseMemory with structured section extraction#747
Alexi5000 wants to merge 1 commit into
Signet-AI:mainfrom
Alexi5000:pr/implement-parse-memory

Conversation

@Alexi5000
Copy link
Copy Markdown
Contributor

Summary

  • Implement parseMemory() in platform/core/src/memory.ts which was a TODO stub returning { raw: markdown }
  • Add a typed ParsedMemory interface with fields: userProfile, keyFacts, ongoingContext, manualNotes, raw
  • Extract content from ## headings matching the template produced by generateMemory()
  • Extract manual notes from the <!-- MANUAL:START --> / <!-- MANUAL:END --> block
  • Export ParsedMemory type from the core package index

Motivation

The parseMemory function was marked as TODO and returned only the raw markdown string. This makes it impossible for consumers to programmatically access individual memory sections without re-parsing. The implementation follows the exact markdown structure defined by generateMemory().

Test Plan

  • Verify parseMemory(generateMemory()) returns empty-string fields for each section (no data stored yet)
  • Verify round-trip: parseMemory(md).raw === md
  • Verify parsing a memory file with populated sections returns the correct content
  • Verify manual notes between MANUAL:START and MANUAL:END are extracted

Replace the stub parseMemory that returned `{ raw: markdown }` with
a real parser that extracts User Profile, Key Facts, Ongoing Context,
and MANUAL notes from the memory markdown format generated by
generateMemory(). Adds a typed ParsedMemory interface and exports it
from the core package.
@PR-Reviewer-Ant
Copy link
Copy Markdown
Collaborator

Hi @Alexi5000 - I'm taking a look at the feature work in feat(core): implement parseMemory with structured section extraction (commit d92a828f) and will follow up shortly.

This comment is updated in place by pr-reviewer.

Copy link
Copy Markdown
Collaborator

@PR-Reviewer-Ant PR-Reviewer-Ant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review metadata
  • Reviewer: pr-reviewer
  • Model: gpt-5.5
  • Commit: d92a828f

The implementation does not match the PR's stated parsing behavior for the generated memory template. In particular, parseMemory(generateMemory()) returns placeholder/comment content instead of empty section fields, and ongoingContext absorbs the manual-note block.

Confidence: High [sufficient_diff_evidence, targeted_context_included] - The changed parser reads every non-heading line after ## Ongoing Context until EOF, while generateMemory() places the manual block after that heading with no following ## heading. The PR test plan also explicitly expects parseMemory(generateMemory()) to return empty-string fields, which this implementation cannot do because it preserves the default placeholder lines as section content.

const headingMatch = line.match(/^##\s+(.+)/);
if (headingMatch) {
// Flush previous section
if (currentSection !== null) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keeps collecting lines after ## Ongoing Context until another ## heading appears, but generateMemory() puts the <!-- MANUAL:START --> ... <!-- MANUAL:END --> block after Ongoing Context without a new heading. As a result, parseMemory(generateMemory()).ongoingContext includes the manual-marker comments, while manualNotes separately extracts the placeholder comment. That diverges from the PR's claim that the generated template parses into empty fields and gives consumers polluted section content.


// Extract manual notes block
const manualMatch = markdown.match(
/<!--\s*MANUAL:START\s*-->([\s\S]*?)<!--\s*MANUAL:END\s*-->/,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser returns the generated placeholder text (*No user profile configured yet.*, *No facts stored yet.*, *No ongoing context.*) as real structured data. The PR test plan says parseMemory(generateMemory()) should return empty-string fields when no data is stored yet, so consumers will incorrectly treat the default template as populated memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants